package com.kaifamiao.collection;

import java.util.Arrays;

public class TestContainer {

    public static void main(String[] args) {

        // Container<String> c = new Container<String>();
        // Java 1.7 开始支持 "钻石运算符" (也称作"菱形语法")
        Container<String> c = new Container<>();

        System.out.println( c.isEmpty() + " , " + c.size() );

        // c.add( 250 ); // 类型不匹配

        c.add( "孙悟空" );
        System.out.println( c );

        c.add( "唐三藏" );
        System.out.println( c );

        c.add( "孙悟空" );
        System.out.println( c );

        System.out.println( c.indexOf( "孙悟空" ) );
        System.out.println( c.lastIndexOf( "孙悟空" ) );
        System.out.println( c.contains( "唐三藏" ) );
        System.out.println( c.contains( "王某然" ) );

        Object[] arr = c.toArray();
        System.out.println( Arrays.toString( arr ) );

        c.remove( "孙悟空" );
        System.out.println( c );

        c.clear();

        System.out.println( c.isEmpty() + " , " + c.size() );


    }

}
